package org.orarriinae.common.base.exception;

import lombok.Getter;

/**
 * 业务异常
 *
 * @author Wang Chengwei
 * @since 1.0
 */
public class ServiceException extends RuntimeException {

    /**
     * 错误编码
     */
    @Getter
    private final String errorCode;

    public ServiceException() {
        super();
        this.errorCode = null;
    }

    public ServiceException(String message) {
        super(message);
        this.errorCode = null;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.errorCode = null;
    }

    public ServiceException(String errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public ServiceException(String errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    public ServiceException(ErrorInfo errorInfo) {
        this(errorInfo.getCode(), errorInfo.getMessage());
    }

    public ServiceException(ErrorInfo errorInfo, Throwable cause) {
        this(errorInfo.getCode(), errorInfo.getMessage(), cause);
    }

    public ServiceException(Throwable cause) {
        super(cause);
        this.errorCode = null;
    }
}
